import mesh.Mesh;
import mesh.Player;

import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.util.vector.Vector3f;

public class Game {
	private Mesh monkey;
	private Mesh cube;
	private Mesh map;
	private Player player;
//	private Camera3D cam3D;
//	private Light3D light3D;

	private static final int GAME_ON = 1;
	
	private int mode = 1;

	public Game() {
		
		setupModels();
		setupCamera();
		setupLights();
		Mouse.setGrabbed(true);
	}

	public void tick() {

		switch (mode) {
		case GAME_ON:
			player.update();
			monkey.draw(player);
			cube.draw(player);
			map.draw(player);
			break;
		}
		
		update();
	}
	
	private void setupModels() {
		map = new Mesh("assets/Map.txt");
		cube = new Mesh("assets/Cube.txt");
		monkey = new Mesh("assets/Data.txt");
		
		map.setPosition(new Vector3f(0, 0, -10));
		cube.setPosition(new Vector3f(2, 0, -10));
		monkey.setPosition(new Vector3f(-2, 0, -10));
	}

	private void setupCamera() {
		
//		cam3D = new Camera3D();
		player = new Player();
		player.setPosition(new Vector3f(0,-10,0));
	}

	private void setupLights() {
		
//		light3D = new Light3D();
	}


	private void update() {		
		
		if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
			if (mode == GAME_ON && Mouse.isGrabbed()) {
				Mouse.setGrabbed(false);
				mode = 0;

			} else {
				System.exit(0);
			}
		}
	}
}
